<template>
    <el-dialog title="详情查看" width="900px" :close-on-click-modal="false" :visible.sync="visible">
        <el-form :inline="true" label-width="150px" :rules="dataRules" ref="dataForm" :model="dataForm">
            <el-form-item label="姓名：" prop="userName">
                <el-input v-model="dataForm.userName"></el-input>
            </el-form-item>
            <el-form-item label="门牌：">
                <el-input v-model="dataForm.doorNumber"></el-input>
            </el-form-item>
            <el-form-item label="性别：">
                <el-input v-model="dataForm.gender"></el-input>
            </el-form-item>
            <el-form-item label="身份证：">
                <el-input v-model="dataForm.idNumber"></el-input>
            </el-form-item>
            <el-form-item label="与户主关系：">
                <el-input v-model="dataForm.relationshipToOwner"></el-input>
            </el-form-item>
            <el-form-item label="联系号码：" prop="contactNumber">
                <el-input v-model="dataForm.contactNumber"></el-input>
            </el-form-item>
            
            <el-form-item label="工作类型：" prop="type">
                <el-select
                    v-model="dataForm.type"
                    placeholder="选择工作类型："
                    style="width: 185px"
                >
                    <el-option value="7" label="技术人员">技术人员</el-option>
                    <el-option value="8" label="教师">教师</el-option>
                    <el-option value="9" label="务工人员">务工人员</el-option>
                    <el-option value="10" label="退休人员">退休人员</el-option>
                    <el-option value="11" label="困难户">困难户</el-option>
                </el-select>
            </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button @click="dataFormCancel()">取消</el-button>
            <el-button type="primary" @click="updateall()">确定</el-button>
        </span>
    </el-dialog>
</template>

<script>
import { treeDataTranslate } from '@/utils';
export default {
    data() {
        return {
            visible: false,
            choesLocation: '',
            oldequipmentId: '',
            dataForm:  {
                regionId: 0,
                buildingName: "",
                buildingAddress: "",
                totalFloors: 0,
                totalUnits: 0,
                yearBuilt: 0,
                propertyCompany: "",
                buildingNo: 0,
                type: 0
            },
            dataListLoading: false,
            menuList: [],
            menuListTreeProps: {
                label: 'typeName',
                children: 'children',
            },
            typeForm: {
                categoryId: '',
                typeName: '',
                typePid: '',
                typePname: '',
                typeId: '',
            },
            dataRules: {
                userName: [{ required: true, message: '姓名不能为空', trigger: 'blur' }],
                doorNumber: [{ required: true, message: '门牌号不能为空', trigger: 'blur' }],
                gender: [{ required: true, message: '性别不能为空', trigger: 'blur' }],
                district: [{ required: true, message: '设备所属区县不能为空', trigger: 'blur' }],
                locationName: [{ required: true, message: '设备位置不能为空', trigger: 'blur' }],
                equipmentId: [{ required: true, message: '设备编码不能为空', trigger: 'blur' }],
                administrator: [{ required: true, message: '管理员姓名不能为空', trigger: 'blur' }],
                phone: [{ required: true, message: '管理员电话不能为空', trigger: 'blur' }],
            },
        };
    },
    methods: {
        init(dataForm) {
            this.dataForm = dataForm;
            this.visible = true;
        },
        // 菜单树选中
        menuListTreeCurrentChangeHandle(data, node) {
            this.typeForm.categoryId = data.typeId;
            this.typeForm.typeName = data.typeName;
            console.log('选中的id = ' + this.typeForm.categoryId);
            console.log('选择的名称 = ' + this.typeForm.typeName);
            this.dataForm.belongTypeid = data.typeId;
            this.dataForm.belongTypename = data.typeName;
        },
        dataFormClear() {
            this.dataForm = {};
        },
        dataFormCancel() {
            this.dataFormClear();
            this.visible = false;
        },
        updateall() {
            let self = this;
            this.$http({
                url: this.$http.adornUrl(`/people/alertPeople`),
                method: 'post',
                data: this.$http.adornData(self.dataForm),
            }).then(({ data }) => {
                if (data && data.code === 0) {
                    self.$message({
                        message: '操作成功',
                        type: 'success',
                        duration: 1500,
                        onClose: () => {
                            self.visible = false;
                            self.dataFormCancel();
                            self.$emit('refreshDataList');
                        },
                    });
                } else {
                    this.$message.error(data.msg);
                }
            });
        },
    },
};
</script>

<style lang="scss"></style>
